
package com.vanda.db.convert;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.vanda.db.XQLData;

/**
 * Collection转换类<br>
 * 
 * @author 王瑛<br>
 * @version Version 1.00<br>
 */
public class CollectionConvert implements Convert {
	/** 设置参数类 */
	private Object param;
	public void setParam(Object param) {
		this.param = param;
	}
	
	/**
	 * 
	 */
	public XQLData parse() {
		XQLData data = new XQLData();
		List lstValue = new ArrayList();
		StringBuffer xqlBuffer = new StringBuffer();
		Iterator iter = ((Collection) param).iterator();
		while (iter.hasNext()) {
			Object obj = iter.next();
			xqlBuffer.append("?,");
			lstValue.add(obj);
		}
		xqlBuffer =
			xqlBuffer.delete(xqlBuffer.length() - 1, xqlBuffer.length());
		data.setXql(xqlBuffer.toString());
		data.setValues(lstValue);
		return data;
	}
}
